package com.willian.andrappfw.ui;

import android.content.Context;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;

import androidx.annotation.NonNull;

import com.willian.andrappfw.R;


public class LoadingGifDialog extends BaseDialog {

    ImageView loadGif;

    /*** 都是内容数据*/
    private final int layoutId;
    private final int gifResId;

    public LoadingGifDialog(@NonNull Context context, int layoutId, int gifResId) {
        super(context);

        this.layoutId = layoutId;
        this.gifResId = gifResId;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setContentView(layoutId);

        //初始化界面
        initView();
        //刷新显示数据以及界面
        refreshView();
    }

    @Override
    protected void initView() {
        loadGif = findViewById(R.id.imageView_loadGif);
    }

    @Override
    protected void refreshView() {
        loadGif.setImageResource(gifResId);

        //处理上面的图标
        if (gifResId != -1){
            loadGif.setImageResource(gifResId);
            loadGif.setVisibility(View.VISIBLE);
        }else {
            loadGif.setVisibility(View.GONE);
        }
    }
}
